const { vital } = require("../utils/log_tool");
const { svn_is_dirty, git_is_dirty } = require("../utils/scm_tool");
const { BaseCommand } = require("./base");

class IsDirtyCommand extends BaseCommand {
    async execute() {
        const data = this.selfData;
        switch (this.selfData.type) {
            case "svn": {
                return await svn_is_dirty(data.cwd);
            }
            case "git": {
                return await git_is_dirty(data.cwd);
            }
            default: {
                throw `不支持的类型 ${this.selfData.type}`;
                break;
            }
        }
    }

    getRequiredParams() {
        return ["type"];
    }
}

module.exports = {
    IsDirtyCommand,
};
